package com.avalon.core.service;

import com.avalon.core.condition.Condition;
import com.avalon.core.exception.AvalonException;
import com.avalon.core.field.Field;
import com.avalon.core.model.*;
import com.avalon.core.model.Record;
import com.avalon.core.util.FieldValue;

import java.util.List;
import java.util.Map;

public interface ISelectService {
    Record select(List<String> fields, Condition condition) throws AvalonException;//查询满足条件的所有记录 以单表形式返回

    Record selectWithObject(List<String> fields, Condition condition) throws AvalonException;//查询满足条件的所有记录 以对象形式返回

    Record selectWithObject(String fields, Condition condition) throws AvalonException;//查询满足条件的所有记录 以对象形式返回

    PageInfo selectPageWithObjectExtend(PageParam pageParam,
                                        String fields,
                                        String order,
                                        Boolean isDistinct,
                                        List<PageConditionHigh> conditions) throws AvalonException;//分页查询满足条件的记录 以对象形式返回

    PageInfo selectPageWithObject(PageParam pageParam,
                                  String fields,
                                  String order,
                                  Boolean isDistinct) throws AvalonException;//分页查询记录 以对象形式返回

    PageInfo selectPageWithObject(PageParam pageParam,
                                  String fields,
                                  String order,
                                  Boolean isDistinct,
                                  Condition condition) throws AvalonException;//分页查询记录 以对象形式返回

    Record select(List<String> fields, Condition condition, String order) throws AvalonException;//查询所有记录 以单表形式返回

    Record select(List<String> fields) throws AvalonException;//查询所有记录 以单表形式返回

    Record selectLimit(List<String> fields, Condition condition, String order, int limit) throws AvalonException;//按条件查询， 以单表形式返回

    Record selectLimit(String fields, Condition condition, String order, int limit) throws AvalonException;//按条件查询， 以单表形式返回

    Record selectLimit(String fields, Condition condition, int limit) throws AvalonException;//按条件查询， 以单表形式返回

    Record selectLimit(List<String> fields, Condition condition, int limit) throws AvalonException;//按条件查询， 以单表形式返回

    Record select(String fields) throws AvalonException;//查询所有记录 以单表形式返回

    Record select(Condition condition) throws AvalonException;//查询所有记录 以单表形式返回

    Record select(String fields, List<PageConditionHigh> pageConditionHighList);//查询所有记录 以单表形式返回

    Record select(String fields, Condition condition) throws AvalonException;//查询所有记录 以单表形式返回

    Record select(String fields, Condition condition, String orderBy) throws AvalonException;//查询所有记录 以单表形式返回

    Record selectList(String fields, Map<String, Object> condition) throws AvalonException;//查询所有记录 以单表形式返回

    Integer selectCount(String fields, Condition condition, String order) throws AvalonException;//查询满足条件记录个数

    Integer selectCount(String fields, Condition condition) throws AvalonException;//查询满足条件记录个数

    Integer selectCount(Condition condition) throws AvalonException;//查询满足条件记录个数

    PageInfo selectPage(PageParam pageParam,
                        String fields,
                        String order,
                        Boolean isDistinct,
                        Condition condition) throws AvalonException;//普通分页查询记录 以单表形式返回

    PageInfo selectPage(PageParam pageParam,
                        String fields,
                        String order,
                        Boolean isDistinct) throws AvalonException;//普通分页查询记录 以单表形式返回

    PageInfo selectPageNormal(PageParam pageParam,
                              String fields,
                              Map<String, Object> condition,
                              String order,
                              Boolean isDistinct) throws AvalonException;//普通分页查询记录 以单表形式返回

    PageInfo selectPageCondition(PageParam pageParam,
                                 String fields,
                                 String order,
                                 Boolean isDistinct,
                                 List<PageCondition> conditions) throws AvalonException;//全and 分页查询满足条件的记录 以单表形式返回

    PageInfo selectPageConditionHigh(PageParam pageParam,
                                     String fields,
                                     String order,
                                     Boolean isDistinct,
                                     List<PageConditionHigh> conditions) throws AvalonException;//高级分页查询满足条件的记录 以单表形式返回

    Condition getConditionByHighListCondition(List<PageConditionHigh> conditions);//转换分页查询条件

    RecordRow selectOne(String fields, Object id) throws AvalonException;//获取满足条件下 指定字段的值

    RecordRow selectOne(List<String> fieldList, Integer id) throws AvalonException;//获取满足条件下 指定字段的值

    RecordRow selectOne(Condition condition, List<String> fieldList) throws AvalonException;//获取满足条件下 指定字段的值

    RecordRow selectOneNoLevel(List<String> fieldList, Condition condition, String order) throws AvalonException;//获取满足条件下 第一条记录

    RecordRow selectOneNoLevel(String fields, Condition condition, String order) throws AvalonException;//获取满足条件下 第一条记录

    RecordRow selectOneNoLevel(String fields, List<PageConditionHigh> conditions, String order) throws AvalonException;//获取满足条件下 第一条记录

    RecordRow selectOne(String fields, Condition condition) throws AvalonException;//获取满足条件下 指定字段的值

    RecordRow selectOne(Integer id) throws AvalonException;//获取满足条件下 指定字段的值

    RecordRow selectOne(Integer id, List<Field> fieldList) throws AvalonException;//获取满足条件下 指定字段的值

    RecordRow selectOne(Integer id, Field... fields) throws AvalonException;//获取满足条件下 指定字段的值

    RecordRow selectOne(Condition condition) throws AvalonException;//获取满足条件下 指定字段的值

    FieldValue getFieldValue(String fieldName, Integer id);//获取字段值 从数据库获取

    FieldValue getFieldValue(String fieldName, Condition condition);//获取字段值 从数据库获取

    FieldValue getFieldValue(Field field, Object id);//获取字段值 从数据库获取

    FieldValue getFieldValue(Field field, Condition condition);//获取字段值 从数据库获取
}
